import pandas as pd
from pyecharts.charts import Line
from pyecharts import options as opts

# Pandas是Python用于数据分析领域的超级牛的库
# Echarts是百度开源的非常好用强大的可视化图表库，Pyecharts是它的Python库版本
def show_photo():
    xlsx_path = "../datas/stocks/baidu_stocks.xlsx"
    # 设置index 列
    df = pd.read_excel(xlsx_path, index_col="datetime", parse_dates=True)
    # print(df.head())
    # print(df.head())
    # 折线图
    line = Line()
    # x轴
    line.add_xaxis(df.index.tolist())
    # 每个y轴
    line.add_yaxis("开盘价", df["open"].round(2).to_list())
    line.add_yaxis("收盘价", df["close"].round(2).to_list())

        # 图表配置
    line.set_global_opts(
        title_opts=opts.TitleOpts(title="百度股票2019年"),
        tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross")
    )
    # 渲染数据
    line.render_notebook()






if __name__ == '__main__':
    show_photo()
